import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import { focus } from '@/utils/directive'

import Vant from "vant";
// 引入全部样式
import "vant/lib/index.less";

import { Lazyload } from 'vant';


// 注册时可以配置额外的选项
Vue.use(Lazyload, {
  lazyComponent: true,
});

// rem移动端适配
import "amfe-flexible";
// 代码高亮的样式
import 'highlight.js/styles/default.css';

// 自动获取焦点指令
Vue.directive("fofo", {
  inserted (el) {
    focus(el)
  },
  update (el) {
    focus(el)
  }
});

Vue.directive("highlight", function (el) {
  // 自定义一个代码高亮指令
  const highlight = el.querySelectorAll("pre, code"); // 获取里面所有pre或者code标签
  highlight.forEach((block) => {
    hljs.highlightElement(block); // 突出显示这些标签(以及内部代码, 会自动识别语言)
  });
});

Vue.config.productionTip = false;

Vue.use(Vant);

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
